#include<stdio.h>
#include<stdlib.h> // malloc

int g_unval;    // 未初始化数据区
int g_val = 10; // 已初始化数据区

int main(int argc, char* argv[], char* env[])
{
    printf("code addr        : %p\n", main); // 代码区

    printf("\n");
    const char *p = "hello";      //全局变量
    printf("read only        : %p\n", p);    // 字符常量区（只读）

    printf("\n");
    printf("global val       : %p\n", &g_val);   // 已初始化数据区
    printf("global uninit val: %p\n", &g_unval); // 未初始化数据区

    printf("\n");
    char *heap_men = (char*)malloc(10);
    char *heap_men2 = (char*)malloc(10);
    char *heap_men3 = (char*)malloc(10);
    printf("head addr        : %p\n", heap_men);  // 堆区（向上增长）
    printf("head addr        : %p\n", heap_men2);
    printf("head addr        : %p\n", heap_men3);
    
    printf("stack addr       : %p\n", &heap_men);     // 栈区（向下增长）
    printf("stack addr       : %p\n", &heap_men2);   //heap_men本质就是main函数里的指针变量，开辟了空间，所以直接&
    printf("stack addr       : %p\n", &heap_men3);
    int i=0;
    for(i=0 ; i < argc; i++)
    {
       printf("argv[%d]: %p\n", i, argv[i]);
    }
    for(i=0;env[i]; i++)
    {
       printf("env[%d]: %p\n ", i, env[i]);
    } 
    return 0;
}
